﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ProgramMain.Framework;

namespace ProgramMain.OpticNet
{
    public partial class FibreDetail : ProgramMain.Framework.BaseModalDetailCtl
    {
        public FibreDetail()
        {
            InitializeComponent();
            this.colorsTableAdapter.SelectCommandTimeout = ProgramMain.Properties.Settings.Default.LongQueryTimeout;
            colorsTableAdapter.Fill(simpleOpticNetDB.Colors);
        }

        private PresentFormType _presentForm;
        public PresentFormType PresentInForm
        {
            get { return _presentForm; }
            set { _presentForm = value; }
        }
    
        protected override void BindDataControls()
        {
            txtLength.DataBindings.Add(new Binding("Text", this.dataSource, "Length"));
            txtFadingDb.DataBindings.Add(new Binding("Text", this.dataSource, "FadingDb"));
            fibre.DataBindings.Add(new Binding("Text", this.dataSource, "Caption"));
            txtConnect1.DataBindings.Add(new Binding("Text", this.dataSource, "ToEquip1"));
            txtConnect2.DataBindings.Add(new Binding("Text", this.dataSource, "ToEquip2"));
            lookUpColor.DataBindings.Add(new Binding("EditValue", this.dataSource, "ColorID"));
            l2.Visibility = PresentInForm == PresentFormType.InEquipment
                                ? DevExpress.XtraLayout.Utils.LayoutVisibility.Never
                                : DevExpress.XtraLayout.Utils.LayoutVisibility.Always;

            layoutColor.Visibility = PresentInForm == PresentFormType.InCables
                                         ? DevExpress.XtraLayout.Utils.LayoutVisibility.Always
                                         : DevExpress.XtraLayout.Utils.LayoutVisibility.Never;
        }
    }
}
